package com.example.servicemap.service;

import com.example.internalcommon.dto.ResponseResult;
import com.example.internalcommon.response.DirectionResponse;
import com.example.servicemap.remote.MapDirectionClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author lyra
 * @Date 2023/4/9 15:57
 **/
@Service
@Slf4j
public class DirectionService {

    @Autowired
    private MapDirectionClient mapDirectionClient;


    /**
     * 12. 根据起点经纬度和终点经纬度获取距离(米)和时长(分钟)
     *
     * @param depLongitude
     * @param depLatitude
     * @param destLongitude
     * @param destLatitude
     * @return
     */
    public ResponseResult driving(String depLongitude, String depLatitude, String destLongitude, String destLatitude) {

        // (1).调用第三方地图接口
        DirectionResponse direction = mapDirectionClient.direction(depLongitude, depLatitude, destLongitude, destLatitude);
        return ResponseResult.success(direction);
    }

}
